import React, { useEffect, useState } from 'react'

export default function UseEffect() {
  const [temp, setTemp] = useState(20)
  const [suggest,setSuggest] = useState('长袖')
  const add = () => {
    setTemp(temp + 5)
  }
  useEffect(() => {
    if (temp >= 30) {
      setSuggest('短袖')
    } else {
      setSuggest('长袖')
    }
  }, [temp])
  return (
    <div>
        <button onClick={add}>add</button>
        <button onClick={() => setTemp(temp - 5)}>minnus</button>
        <div>{temp}</div>
        <div>建议穿衣：{suggest}</div>
    </div>
  )
}
